#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e5 + 10;
int arr[N];
int main()
{
	int n;
	cin >> n;
	string a;
	cin >> a;
	int ans = 0;
	int j = 0;
	int ans2 = 0;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] == '0') {
			arr[j++] = i;
			ans++;
		}
		if (a[i] == '1') {
			ans2++;
		}
	}
	if (a[0] == '0' && a[a.size()-1]!='1') {
		cout << 2 << endl;
	}
	else {
		if (ans2 == a.size()) {
			cout << 0 << endl;
		}
		else {
			cout << 1 << endl;
		}
	}
	return 0;
}